<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Call a function in a Lua global variable</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.luasandbox.html">« LuaSandbox</a></li>
      <li style="float: right;"><a href="luasandbox.disableprofiler.html">LuaSandbox::disableProfiler »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.luasandbox.html">LuaSandbox</a></li>
    <li>Call a function in a Lua global variable</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="luasandbox.callfunction" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">LuaSandbox::callFunction</h1>
  <p class="verinfo">(PECL luasandbox &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">LuaSandbox::callFunction</span> &mdash; <span class="dc-title">Call a function in a Lua global variable</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-luasandbox.callfunction-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>LuaSandbox::callFunction</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>, <span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">...$args</code></span>): <span class="type"><span class="type">array</span>|<span class="type">bool</span></span></div>

  <p class="para rdfs-comment">
   Calls a function in a Lua global variable.
  </p>
  <p class="para">
   If the name contains &quot;.&quot; characters, the function is located via
   recursive table accesses, as if the name were a Lua expression.
  </p>
  <p class="para">
   If the variable does not exist, or is not a function, false will be
   returned and a warning issued.
  </p>
  <p class="para">
   For more information about calling Lua functions and the return values,
   see <span class="methodname"><a href="luasandboxfunction.call.html" class="methodname">LuaSandboxFunction::call()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-luasandbox.callfunction-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">name</code></dt>

    <dd>

     <p class="para">
      Lua variable name.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">args</code></dt>

    <dd>

     <p class="para">
      Arguments to the function.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-luasandbox.callfunction-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an <span class="type">array</span> of values returned by the Lua function, which may be empty, or <code class="literal">false</code> in case of failure.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-luasandbox.callfunction-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3435">
    <p><strong>示例 #1 Calling a Lua function</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;create&nbsp;a&nbsp;new&nbsp;LuaSandbox<br /></span><span style="color: #0000BB">$sandbox&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">LuaSandbox</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;Call&nbsp;Lua's&nbsp;string.match<br /></span><span style="color: #0000BB">$captures&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$sandbox</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">callFunction</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'string.match'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$string</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$pattern&nbsp;</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


</div></div></div></body></html>